C++功课```急````快而且正确的`马上加分``

来源:百度知道 编辑:UC知道 时间:2024/09/26 00:23:54
分别写两个程序显示平行四边形:
第一种情况:(实心)
例:
This program will output a parallelogram.
How long do you want each side to be? 6
Please enter the character you want it to be made of: @
@
@@
@@@
@@@@
@@@@@
@@@@@@
@@@@@
@@@@
@@@
@@
@
This program will output a parallelogram.
How long do you want each side to be? 9
Please enter the character you want it to be made of: *
*
**
***
****
*****
******
*******
********
*********
********
*******
******
*****
****
***
**
*
第二种情况:(空心)
This program will output a parallelogram.
How long do you want each side to be? 6
Please enter the character you want it to be made of: @
@
@@
@ @
@ @
@ @
@ @
@ @
@ @
@ @

1.#include "stdio.h"
main()
{ int n,i,j;
char ch;
printf("this program will output:\n");
printf("\nplease input the character you will want to be made up of:\n");
scanf("%c",&ch);
printf("how long will you want to output:\n");
scanf("%d",&n);
printf("the output is :\n");
for(i=0;i<n;i++)
{ for(j=0;j<=i;j++)
printf("%c ",ch);
printf("\n");
}
for(i=n-1;i>=0;i--)
{ for(j=0;j<=i;j++)
printf("%c ",ch);
printf("\n");
}
}

2. #include "stdio.h"
main()
{ int n,i,j;
char ch;
printf("this program will output:\n");
printf("\nplease input the character you will want to be made up of:\n");